package com.lancoo.cvas.service;

import com.lancoo.cvas.entity.*;
import com.lancoo.cvas.pojo.input.ClassInfoByClassInput;
import com.lancoo.cvas.pojo.dto.FixDto;
import com.lancoo.cvas.pojo.input.ClassInfoByMajorInput;
import com.lancoo.cvas.pojo.vo.*;
import com.lancoo.cvas.util.Result;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

public interface BasicRuleService {

    /**
     * 跨校区设置列表
     *
     * @param taskId
     * @param gradeId
     * @param keyword
     * @param campusId
     * @param currentPage
     * @param pageSize
     * @return
     */
    CampusCrossGetResponse getClassInfo(Integer taskId,  String gradeId, String keyword, String campusId, Integer currentPage, Integer pageSize);

    /**
     * @param taskId:
     * @param weekSet:       大小周设置
     * @param schoolId:
     * @param term:
     * @param periodSchemes: 课时方案列表
     * @Description: 初始化课时方案设置
     * @Author: liufeng
     * @Date: 2023/12/4 20:02
     * @return:
     */
    void initWeekDays(Integer taskId, Integer weekSet, String schoolId, String term, List<PeriodScheme> periodSchemes);

    /**
     * @param schoolId:
     * @param term:
     * @Description: 根据学校id 学期id获取课时方案设置
     * @Author: liufeng
     * @Date: 2023/12/4 20:15
     * @return:
     */
    List<PeriodSchemeGroupVo> getPeriodSchemes(Integer taskId, String schoolId, String term);

    /**
     * @param schoolId:
     * @param term:
     * @Description: 根据学校id 学期id获取课时方案设置
     * @Author: liufeng
     * @Date: 2023/12/4 20:27
     * @return:
     */
    List<RuleWeekDay> getWeekDays(Integer taskId, String schoolId, String term);

    /**
     * @param taskId:
     * @param weekDays:
     * @Description: 更新课时方案设置，暂时同一个学校同一个学期只有第一个任务时可以设置
     * @Author: liufeng
     * @Date: 2023/12/5 9:40
     * @return:
     */
    Boolean updateWeekDay(Integer taskId, List<RuleWeekDay> weekDays);


    /**
     * 初始化基础规则
     *
     * @param taskId
     * @param schoolId
     * @param term
     */
    void initRuleUsable(Integer taskId, String schoolId, String term);


    /**
     * 批量修改校区
     *
     * @param classIds
     * @param campusId
     * @param campusName
     * @return
     */
    boolean setCampus(List<Long> classIds, String campusId, String campusName);

    /**
     * @param schoolId:
     * @param term:
     * @param schoolId:
     * @param term:
     * @Description: 根据学校id 学期id获取课时设置最大课时
     * @Author: liufeng
     * @Date: 2023/12/5 14:20
     * @return:
     */
    MaxPeriodScheme getMaxPeriodScheme(Integer taskId, String schoolId, String term);

    /**
     * @param schoolId:
     * @param term:
     * @Description: 根据学校id 学期id获取日期禁排
     * @Author: liufeng
     * @Date: 2023/12/5 15:01
     * @return:
     */
    List<RuleTimeProhibit> getTimeProhibit(Integer taskId, String schoolId, String term);

    /**
     * @param taskId:
     * @param ruleTimeProhibit:
     * @Description: 设置日期禁排 相当于禁排所有周次的某一节课
     * @Author: liufeng
     * @Date: 2023/12/5 19:21
     * @return:
     */
    Integer setTimeProhibit(Integer taskId, RuleTimeProhibit ruleTimeProhibit);


    /**
     * @param taskId:
     * @Description: 清空课时禁排
     * @Author: liufeng
     * @Date: 2023/12/14 18:57
     * @return:
     */
    Boolean clearTimeProhibit(Integer taskId);

    /**
     * @param setBasciRuleRequest:
     * @Description: 设置基础规则
     * @Author: liufeng
     * @Date: 2023/12/5 19:27
     * @return:
     */
    void setBasicRule(SetBasciRuleRequest setBasciRuleRequest);

    /**
     * @param taskId:
     * @param schoolId:
     * @param term:
     * @Description: 获取基础规则
     * @Author: liufeng
     * @Date: 2023/12/5 19:37
     * @return:
     */
    List<RuleUsable> getCurrent(Integer taskId, String schoolId, String term);

    /**
     * 按班级设置上课范围
     *
     * @param taskId
     * @param gradeId
     * @param keyWord
     * @param currentPage
     * @param pageSize
     * @return
     */
    ClassInfoByClassResponses getClassInfoByClass(Integer taskId, String gradeId, String keyWord, Integer currentPage, Integer pageSize);

    /**
     * @param importProhibit:
     * @param file:
     * @Description: 导入禁排
     * @Author: liufeng
     * @Date: 2023/12/5 20:24
     * @return:
     */
    Result excelToProhibit(HttpServletResponse response, ImportProhibit importProhibit, MultipartFile file);


    /**
     * 按专业设置上课范围
     *
     * @param taskId
     * @param majorId
     * @param gradeId
     * @param currentPage
     * @param pageSize
     * @return
     */
    ClassInfoByMajorResponse getClassInfoByMajor(Integer taskId, String majorId, String gradeId, String keyWord,Integer currentPage, Integer pageSize);


    /**
     * @param schoolId:
     * @param term:
     * @param roomId:
     * @Description: 根据id获取教室禁排时间
     * @Author: liufeng
     * @Date: 2023/12/6 15:44
     * @return:
     */
    List<RuleRoomProhibit> getRoomProhibit(Integer taskId, String schoolId, String term, Long roomId);

    /**
     * @param taskId:
     * @param ruleRoomProhibit:
     * @Description: 设置教师禁排时间
     * @Author: liufeng
     * @Date: 2023/12/6 16:45
     * @return:
     */
    boolean setRoomProhibit(Integer taskId, RuleRoomProhibit ruleRoomProhibit);


    /**
     * 通过年级id和专业id获取班级信息
     *
     * @param taskId
     * @param gradeId
     * @param majorId
     * @return
     */
    List<ClassVo> getClassVo(Integer taskId,String gradeId,Long majorId);


    /**
     * 按班级设置生成教学班
     * @param classInfos
     * @return
     */
    Integer addTeachingClassByClass(Integer taskId, ClassInfoByClassInput classInfos);


    /**
     * 按专业设置生成教学班
     *
     * @param gradeInfos
     * @return
     */
    Integer addTeachingClassByMajor(Integer taskId, ClassInfoByMajorInput gradeInfos);

    /**
     * @param taskId:
     * @param schoolId:
     * @param roomId:
     * @param courseId:
     * @param classId:
     * @param teachingClassId:
     * @param teacherId:
     * @Description: 固排时检查禁排课时
     * @Author: liufeng
     * @Date: 2023/12/6 20:16
     * @return:
     */
    ProhibitCheckVo checkProhibit(Integer taskId, String schoolId, Long roomId, Long courseId, String classId, Long teachingClassId, String teacherIds);

    /**
     * @param taskId:
     * @param fixDto:
     * @Description: 设置固排
     * @Author: liufeng
     * @Date: 2023/12/7 9:54
     * @return:
     */
    FixVo setFix(Integer taskId, String schoolId, String term, List<FixDto> fixDto);

    Boolean removeFix(Integer taskId, String schoolId, String term, List<RuleTeachingClassProhibit> ruleList);

    FixVo getFixConflict(Integer taskId, List<FixDto> fixDto);

    FixVo checkProhibitConflictWithRule(Integer taskId, List<FixDto> fixDto, List<RuleUsable> rules);
    FixVo checkProhibitConflict(Integer taskId, List<FixDto> fixDto, List<RuleUsable> rules);

    /**
     * 获取教师统一设置
     *
     * @param taskId
     * @return
     */
    RuleTeacherSetting getTeacherSetting(Integer taskId);

    /**
     * 设置教师统一设置
     *
     * @param ruleTeacherSetting
     * @return
     */
    Boolean setTeacherSetting(RuleTeacherSetting ruleTeacherSetting);

    /**
     * @param taskId:
     * @param schoolId:
     * @param term:
     * @param teacherId:
     * @Description: 获取教师禁排
     * @Author: liufeng
     * @Date: 2023/12/7 19:06
     * @return:
     */
    List<RuleTeacherTime> getTeacherProhibit(Integer taskId, String schoolId, String term, Integer teacherId);

    /**
     * 设置教师禁排
     *
     * @param ruleTeacherTime
     * @return
     */
    boolean setTeacherTimeProhibit(Integer taskId, RuleTeacherTime ruleTeacherTime);

    List<RuleClassProhibit> getClassProhibit(Integer taskId, String schoolId, Long classId);

    boolean setClassProhibit(Integer taskId, RuleClassProhibit ruleClassProhibit);

    List<RuleTeachingClassProhibit> getTeachingClassProhibit(Integer taskId, String schoolId, Long teachingClassId);

    boolean setTeachingClassProhibit(Integer taskId, RuleTeachingClassProhibit ruleTeachingClassProhibit);


    List<RuleUsable> getBaseRule(Integer taskId);

    Boolean setBaseRule(Integer taskId, List<RuleUsable> ruleUsableList);

    List<RuleTeachingClassVo> getRuleTeachingClass(Integer taskId, Long roomId, Long teacherId, Long classId, Long teachingClassId);

    /**
     * 删除所有规则
     * @param taskIds
     */
    void removeAllRule(List<Integer> taskIds);

    Boolean checkTaskInfoName(String taskInfoName);

    Result<Object> syncUpdatePeriodSchemes(Integer taskId, String schoolId, String term);
}
